package cn.jmz.micpro.controller.user;

import cn.jmz.micpro.common.result.GlobalResult;
import cn.jmz.micpro.entity.db.user.User;
import cn.jmz.micpro.entity.dto.user.UserBaseLogin;
import cn.jmz.micpro.entity.dto.user.UserMobileLogin;
import cn.jmz.micpro.service.impl.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户接口")
@RestController
@RequestMapping("/user")
public class UserController {

    private UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @ApiImplicitParam(name = "user",value = "用户基础登录信息",required = true)
    @ApiOperation(value = "账号密码登录")
    @PostMapping("/baseLogin")
    public GlobalResult baseLogin(@RequestBody UserBaseLogin userBaseLogin) {
        return userService.baseLogin(userBaseLogin);
    }

    @ApiImplicitParam(name = "user",value = "用户短信登录信息",required = true)
    @ApiOperation(value = "短信验证码登录")
    @PostMapping("/mobileLogin")
    public GlobalResult mobileLogin(@RequestBody UserMobileLogin userMobileLogin) {
        return userService.mobileLogin(userMobileLogin);
    }

    @ApiImplicitParam(name = "user",value = "用户入参",required = true)
    @ApiOperation(value = "新增或者更新用户")
    @PostMapping("/save")
    public GlobalResult saveUser(@RequestBody User user){
        return null;
    }

}
